#include <iostream>
#include <cstring>

#define MAX_STR_SIZE       10
#define MAX_SUBSTR_SIZE    3

using namespace std;

unsigned int find_max_char_idx(const char* str)
{
    unsigned int i, max_idx;

    i = max_idx = 0;

    while(str[i] != '\0')
    {
        if (str[i] > str[max_idx])
            max_idx = i;

        i++;
    }

    return max_idx;
}

int main(void)
{
    char str[MAX_STR_SIZE+1];
    char substr[MAX_SUBSTR_SIZE+1];
    char result_str[MAX_STR_SIZE+MAX_SUBSTR_SIZE+1];

    while(cin>>str>>substr && !cin.eof())
    {
        unsigned int max_idx;

        max_idx = find_max_char_idx(str);

        strncpy(result_str, str, max_idx+1);

        result_str[max_idx+1] = '\0';

        strcat(result_str, substr);

        strcat(result_str, str+max_idx+1);

        cout<<result_str<<endl;
    }

    return 0;
}

